﻿@model ABCTile.ViewModel.EstimateIndexData

@{
    ViewBag.Title = "Estimate";
}

<h2>Estimates</h2>

@using (Html.BeginForm())
{
    @Html.DropDownList("id", new SelectList(ViewBag.Estimate));
    <input type="submit" value = "Filter" />    
}

<p> 
    @Html.ActionLink("Create New Estimate", "Create") 
</p> 


<table>
    <tr>
        <th></th>
        <th>
            Project Id
        </th>
        <th>
            Estimate Total
        </th>
        <th>
            Estimate Date
        </th>
        <th>
            Estimate Comment
        </th>
        <th>
            Estimate Status
        </th>
        
    </tr>

    @foreach (var item in Model.Estimates)
    {

        string selectedRow = "";
        if (item.Id == ViewBag.EstimateID)

        {
            selectedRow = "selectedrow";
        }

        <tr class="@selectedRow" valign="top">  
            <td>  
                @Html.ActionLink("Select", "Index", new { id = item.Id }) |  
                @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |  
                @Html.ActionLink("Details", "Details", new { id = item.Id }) |  
                @Html.ActionLink("Delete", "Delete", new { id = item.Id })  
                @Html.ActionLink("Finalize", "Index", "Proposal", new { id = item.Id }, null)
            </td>  
            <td>  
                @item.ProjectId  
            </td>  
            <td>  
                @item.EstimateTotal 
            </td>  
            <td>  
                @item.EstimateDate 
            </td>  
            <td>  
                @item.EstimateComment 
            </td>  
            <td>  
                @item.EstimateStatus 
            </td>  
        </tr>  
    }

</table>

@if (Model.EstimateDetails != null)
{
    
       <h3>Detail For Estimate</h3>  

<p>
    @Html.ActionLink("Create New Detail", "EDCreate")
</p>
<table>
    <tr>
         <th>
            Section
        </th>
        <th>
            Product
        </th>
        <th>
            Quantity
        </th>
        <th>
            Price Per Qty
        </th>
        <th>
            Section Total
        </th>
        <th>
            Price Experation Date
        </th>
        <th>
            Vendor Name
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model.EstimateDetails)  
    {        
        string selectedRow = "";  
        if (item.EstimateId == ViewBag.EstimateID)  
        {  
            selectedRow = "selectedrow";  
        }
        var SectionTotal = item.Quantity * item.PricePerQty;
        
    <tr class="@selectedRow">  
          <td>  
            @item.Section  
        </td>  
        <td>  
            @item.Product  
        </td>  
        <td>  
            @item.Quantity  
        </td>  
       <td>  
            @item.PricePerQty  
        </td> 
        <td>
            @SectionTotal
        </td>         
        <td>  
            @item.PriceExperationDate 
        </td>
       <td>  
            @item.VendorName 
        </td>  

        <td>
            @Html.ActionLink("Edit", "EDEdit", new { id = item.Id }) |
            @Html.ActionLink("Details", "EDDetails", new { id = item.Id }) |
            @Html.ActionLink("Delete", "Delete", "EstimateDetail", new { id = item.Id }, null)
        </td>
    </tr>  
    }  

</table>

    <h3>The Estimate Total is:</h3>  
    @ViewBag.zoutotal
}

